@import 'tailwindcss';

@source '../../../packages/stack-shared/src';

@import 'fumadocs-ui/css/black.css';
@import 'fumadocs-ui/css/preset.css';
@import 'fumadocs-openapi/css/preset.css';
@import '../components/mdx/mdx-info.css';
@import '../components/mdx/mdx-cards.css';
@import '../components/mdx/reset-code-styles.css';

:root {
  --color-fd-background: #fafbfd;
}

.dark {
  --color-fd-background: hsl(0, 0%, 7.04%);
}

[id] {
  scroll-margin-top: 7rem;
}

/* Standardize top spacing between docs and API pages */
/* Target the specific fumadocs layout components */
#nd-page > article > div {
  padding-top: 0 !important;
}

/* Target SharedContentLayout container in docs pages */
#nd-page article > div.container {
  padding-top: 0 !important;
}

/* Main sidebar collapsed state */
#nd-docs-layout {
  transition: margin-left 300ms ease-out;
}

#api-main-content {
  transition: margin-left 300ms ease-out;
}

body.main-sidebar-collapsed .api-sidebar {
  width: 4rem !important; /* 64px collapsed width */
  transition: width 300ms ease-out;
}

/* Default transitions for main content */
#nd-docs-layout {
  transition: margin-left 300ms ease-out;
}

#api-main-content {
  transition: margin-left 300ms ease-out;
}

.api-sidebar {
  transition: width 300ms ease-out;
}

/* TOC open state - only when chat is not open */
body.toc-open:not(.chat-open):not(.home-page) {
  padding-right: 16rem; /* same as w-64 */
  transition: padding-right 300ms ease-out;
}

/* Chat open state - overrides everything */
body.chat-open:not(.home-page) {
  padding-right: 24rem; /* 384px */
  transition: padding-right 300ms ease-out;
}

/* Auth open state - for API pages */
body.auth-open:not(.home-page) {
  padding-right: 24rem; /* 384px (auth panel is 384px wide) */
  transition: padding-right 300ms ease-out;
}

/* Default transition for docs pages */
body:not(.home-page) {
  transition: padding-right 300ms ease-out;
}

/* Chat drawer content shifting for homepage */
body.home-page.chat-open main {
  padding-right: 12rem; /* Much less padding for homepage */
  transition: padding-right 300ms ease-out;
}

/* Ensure smooth transition when closing for homepage main content */
body.home-page main {
  transition: padding-right 300ms ease-out;
}

/* Special chat drawer positioning for homepage */
body.home-page [data-chat-drawer] {
  /* Start from top when pill is not visible */
  top: 56px; /* Same as top-14 */
  height: calc(100vh - 56px);
  transition: top 300ms ease-out, height 300ms ease-out;
}

/* When scrolled on homepage, adjust for pill navbar */
body.home-page.scrolled [data-chat-drawer] {
  top: 0;
  height: 100vh;
}

/* Flat scrollbar design for compact codeblocks */
.compact-codeblock-scrollbar::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.compact-codeblock-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}

.compact-codeblock-scrollbar::-webkit-scrollbar-thumb {
  background: #404040;
  border-radius: 0px;
  border: none;
}

.compact-codeblock-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #525252;
}

.compact-codeblock-scrollbar::-webkit-scrollbar-corner {
  background: transparent;
}

/* Subtle pulsing red animation for auth panel errors */
@keyframes subtle-red-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.auth-error-pulse {
  animation: subtle-red-pulse 2s ease-in-out infinite;
}

/* Colorful moving gradient animation for chat button */
@keyframes gradient-shift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@keyframes gradient-noise {
  0% {
    background-position: 0% 0%, 100% 100%;
  }
  25% {
    background-position: 100% 0%, 0% 100%;
  }
  50% {
    background-position: 100% 100%, 100% 0%;
  }
  75% {
    background-position: 0% 100%, 0% 0%;
  }
  100% {
    background-position: 0% 0%, 100% 100%;
  }
}

.chat-gradient-active {
  position: relative;
  background: hsl(var(--fd-muted)) !important;
}

.chat-gradient-active::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: 
    linear-gradient(45deg, rgba(139, 92, 246, 0.95), rgba(236, 72, 153, 0.95), rgba(59, 130, 246, 0.95), rgba(6, 182, 212, 0.95)),
    linear-gradient(-45deg, rgba(236, 72, 153, 0.8), rgba(59, 130, 246, 0.8), rgba(139, 92, 246, 0.8), rgba(6, 182, 212, 0.8)),
    linear-gradient(90deg, rgba(139, 92, 246, 0.85), rgba(6, 182, 212, 0.85), rgba(236, 72, 153, 0.85));
  background-size: 400% 400%, 300% 300%, 200% 200%;
  animation: 
    gradient-shift 8s ease-in-out infinite,
    gradient-noise 12s linear infinite;
  z-index: 0;
}

/* When not active, mask shrinks back */
button:not(.chat-gradient-active)::before {
  mask: radial-gradient(circle at 20% 80%, transparent 0%, transparent 100%);
  transition: mask 0.3s ease-out;
}

/* Hide scrollbars for embedded iframe content */
.scrollbar-hide {
  -ms-overflow-style: none;  /* Internet Explorer 10+ */
  scrollbar-width: none;  /* Firefox */
}
.scrollbar-hide::-webkit-scrollbar {
  display: none;  /* Safari and Chrome */
}

/* Prevent horizontal overflow in embedded iframe content */
.prose {
  /* Only break words when absolutely necessary, not all the time */
  overflow-wrap: break-word;
  word-wrap: break-word;
  /* Remove aggressive word-break that was breaking normal text */
}

.prose pre {
  /* Prevent code blocks from causing horizontal scroll */
  overflow-x: auto;
  max-width: 100%;
}

.prose code {
  /* Only break very long unbreakable strings, not normal code */
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.prose table {
  /* Make tables responsive */
  display: block;
  overflow-x: auto;
  white-space: nowrap;
  max-width: 100%;
}

.prose img {
  /* Ensure images don't overflow */
  max-width: 100%;
  height: auto;
}

/* Only break URLs and very long unbreakable strings */
.prose a[href*="://"] {
  overflow-wrap: anywhere;
}

/* Break very long strings that have no spaces (like tokens, hashes, etc.) */
.prose code:not(pre code) {
  overflow-wrap: anywhere;
}

/* Ensure EnhancedAPIPage components fill their container */
.api-content-container {
  width: 100%;
  max-width: none !important;
}
